package com.li.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.li.model.UserModel;
import com.li.mapper.UserMapper;
import com.li.pojo.DataDto;
import com.li.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.cursor.Cursor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LRC
 * @since 2021-02-22
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserModel> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
   /* @Cacheable(value = "hello1")*/
    public List<UserModel> getUserList() {
        QueryWrapper<UserModel> userModelQueryWrapper = new QueryWrapper<>();
        return userMapper.selectList(userModelQueryWrapper);
    }

    @Override
  /*  @Cacheable(value = "hello2")*/
    public List<UserModel> getUserList2() {
        QueryWrapper<UserModel> userModelQueryWrapper = new QueryWrapper<>();
        userModelQueryWrapper.eq("id", 3);
        return userMapper.selectList(userModelQueryWrapper);
    }

    @Override
    public void addMore() {
        String taleName = "is_user";
        List<UserModel> userList = new LinkedList<>();
        UserModel userModel = new UserModel();
        userModel.setName("老郭");
        userModel.setAge(18);
        userList.add(userModel);

        UserModel userModel2 = new UserModel();
        userModel.setName("老王");
        userModel.setAge(18);
        userList.add(userModel);
        userMapper.addMore(taleName, userList);
    }

    @Override
    public List<DataDto> getUserList3() {
        return userMapper.getUserList3();
    }

    @Override
    public Cursor<UserModel> getUserList4() {
        return userMapper.getUserList4();
    }
}
